//**************************************************
//	Digit Widgets Angles Module
// 	Object Manipulation by Angle and Distance
//	Made to be called from Hyperlinked Digit_Widgets Script
//
//	Version 3.0 - 09/12/01 - Updated with Animation Script
//	Version 3.1 - 09/15/01 - Updated with Advanced and Standard Animation Scripts
//**************************************************
<zscriptinsert,"Digit_Widgets_Common.txt">
[PD]
[FontSetColor,255,200,0]Angle Functions[FontSetColor,160,160,160]
[PD]
//***************************
//Angle Manipulation Variables
//***************************
[VarDef,xtmp,0]
[VarDef,ytmp,0]
[VarDef,ztmp,0]
[VarDef,tmp,0]
[VarDef,tmp1,0]
[VarDef,XD1,0]
[VarDef,YD1,0]
[VarDef,ZD1,0]
[VarDef,aincr,0]
[VarDef,zincr,0]
[VarDef,Trad,0]
[VarDef,ypt,0]
[VarDef,xpt,0]
[VarDef,zpt,0]
[VarDef,recip,0]
[VarDef,Dmult,1]
[VarDef,DIST,0]
[VarDef,ZSlope,0]
[varDef,pangle,0]
[iSlider,"Distance",0,.1,-1000,1000,"Select Distance",[VarSet,DistToMark,zscript:Distance],0,[TextCalcWidth,Distance1453]]
[iSlider,"XYAngle",0,.1,-1000,1000,"Select Angle",[VarSet,dangle,zscript:XYAngle],0,[TextCalcWidth,XYAngle12345]]
[iSlider,"ZAngle",0,.1,-1000,1000,"Select Z Angle + or -",[VarSet,ZSlope,zscript:ZAngle],0,[TextCalcWidth,ZAngle123456]]
[iSlider,"AngleIncr",0,.1,-360,360,"Select Angle Increment  ",[VarSet,aincr,zscript:AngleIncr],0,[TextCalcWidth,AngleIncr4123]]
[iSlider,"ZAngleIncr",0,.1,-360,360,"Select ZAngle Increment ",[VarSet,zincr,zscript:ZAngleIncr],0,[TextCalcWidth,AngleIncr4123]]
[iSwitch,"Snapit",0,"Perform Snapshot"] 
[iSwitch,"DoSize",0,"Size to Position"] 
[iSwitch,"AutoSpace",0,"adjust spacing to Z Position"] 
[iSwitch,"AnglePoint",0,"Rotate Object to point at NosePoint"] 
[iSwitch,"LastPoint",0,"Rotate Object to point at the Last Move",
	//there is a problem with the first move in that what is the last move? so I will help this situation by doing this
	[if,[isDisabled,transform:move],
		//if no object is selected then make it the current pointer coords
		[VarSet,kx,curmX]
		[VarSet,ky,curmY]
		[VarSet,kz,curmZ]
	,//else
		//make it the current object coords
		[TransformGet,kx,ky,kz]
	]

] 
[iSwitch,"Lineit",0,"Make line to Pointer"]
[iSwitch,"Ladder",0,"Make Object Ladder",
	//there is a problem with the first move in that what is the last move? so I will help this situation by doing this
	[if,[isDisabled,transform:move],
		//if no object is selected then make it the current pointer coords
		[VarSet,kx,curmX]
		[VarSet,ky,curmY]
		[VarSet,kz,curmZ]
	,//else
		//make it the current object coords
		[TransformGet,kx,ky,kz]
	]
] 
[iButton,"A-ShiftAxis","Change RGB Axis for Shifting Color",
	[VarInc,Aptr]
	[if,Aptr=3,[VarSet,Aptr,0]]
	[if,Aptr=0,	[note,"XYZ = RGB",,1]]
	[if,Aptr=1,	[note,"XYZ = GBR",,1]]
	[if,Aptr=2,	[note,"XYZ = BRG",,1]]
		
]
[iSwitch,"A-ShiftColor",0,"Span Color Gradient"] 
[iSwitch,"A-ZColorit",0,"Set Color according to Zdepth"] 
[iSwitch,"AConformit",0,"Set Z to Canvas"]
[iSwitch,"ANormalit",0,"Set Rotation to the normals on the canvas"]
[iSwitch,"FromMark",0,"Center Object at current Mark"] 
[PD]

[iButton," Calc_Angle ","Calculate Dist and Angle to Mark",
	[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
	[RoutineCall,GetAngle,IcurrX,MarkX(MarkIndex),IcurrY,MarkY(MarkIndex)]
	[ISet,zscript:XYangle,dangle]
	[RoutineCall,GetDistance,IcurrX,MarkX(MarkIndex),IcurrY,MarkY(MarkIndex)]
	[ISet,zscript:Distance,DistToMark]
]


[iButton," Place_angle ","Use Dist and Angle to Place object",
	[if,[iGet,zscript:FromMark],
		[TransformSet,MarkX(MarkIndex),MarkY(MarkIndex),MarkZ(MarkIndex),MarkXS(MarkIndex),MarkYS(MarkIndex),MarkZS(MarkIndex)]
	]
	
	[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]

	//autospace
	[if,[iGet,zscript:AutoSpace],
		[RoutineCall,DistCalc]
		[VarSet,DIST,DistToMark*Dmult]
	,//else
		[VarSet,DIST,DistToMark]
	]//endif

	//xy position
	[RoutineCall,GetPosition,dangle,Zslope,DIST]

	[VarSet,XD1,IcurrX+xpt]
	[VarSet,YD1,IcurrY+ypt]
	[VarSet,ZD1,IcurrZ+zpt]

	//use pixol to get z depth
	[if,[IGet,zscript:AConformit],
		//[TransformGet,Kpointx(0),KpointY(0),Kpointz(0),IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
		//move out of way temporary
		[TransformSet,0,0,0]
		[RoutineCall,PixolLook,XD1,YD1,GetDepthandMat,ZD1,dummy,dummy,dummy]
		[if,[IGet,zscript:ANormalit],
			[RoutineCall,PixolLook,XD1,YD1,GetNorms,Normx,Normy,Normz,dummy]
			[VarSet,Normx,XD1+(Normx*DIST)]
			[VarSet,Normy,YD1+(Normy*DIST)]
			[VarSet,Normz,ZD1+(Normz*DIST)]
			[routineCall,PointFromTo,XD1,YD1,ZD1,Normx,Normy,Normz,Xangle,Yangle]
			[transformSet,,,,,,,Xangle,Yangle,CurrZR]
		]

		//[messageOK,xd1]
	]

	//Draw new position
	[TransformSet,XD1,YD1,ZD1]


	[if,[iGet,zscript:DoSize],
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
		[RoutineCall,DepthCalc]
	]//Endif

	[if,[iGet,zscript:Ladder],
		//get angle to pointer
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
		[RoutineCall,MakeLine,XD1,KX,YD1,KY,ZD1,KZ,currzr]
		//move back
	//	[TransformSet,XD1,YD1,ZD1]
		[VarSet,KX,XD1]
		[VarSet,KY,YD1]
		[VarSet,KZ,ZD1]
	]

	[if,[iGet,zscript:LineIt],
		//get angle to pointer
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
		[RoutineCall,MakeLine,XD1,curmx,YD1,curmy,ZD1,curmz,currzr]
		//move back
		[TransformSet,XD1,YD1,ZD1]
	]
	
	[if,[IGet,zscript:Anglepoint],
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
		[routineCall,PointFromTo,ICurrX,ICurrY,ICurrZ,curmX,curmY,curmZ,Xangle,Yangle]
		[transformSet,,,,,,,Xangle,Yangle,CurrZR]
	]
	
	[if,[IGet,zscript:LastPoint],
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
		[routineCall,PointFromTo,ICurrX,ICurrY,ICurrZ,kx,ky,kz,Xangle,Yangle]
		[transformSet,,,,,,,Xangle,Yangle,CurrZR]
		[VarSet,KX,XD1]
		[VarSet,KY,YD1]
		[VarSet,KZ,ZD1]
	]

	[if,[iGet,zscript:A-ShiftColor],
		[RoutineCall,ShiftColor,XD1,YD1,ZD1,aptr]
	]

	[if,[iGet,zscript:A-ZColorit],
		[RoutineCall,ZcolorCalc,XD1,YD1,ZD1]	
	]

	[if,[iGet,zscript:Snapit],
		[IPress,Transform:Snapshot]
	]//endif


	//add XY Angle increment if there is any
	[VarAdd,dangle,aincr]
	[if,dangle>360,
		[VarSet,dangle,dangle-360]]

	[if,dangle<-360,
		[VarSet,dangle,dangle+360]]

	[ISet,zscript:XYAngle,dangle]
	
	[VarAdd,ZSlope,zincr]
	[if,ZSlope>360,
		[VarSet,ZSlope,ZSlope-360]]
	[if,ZSlope<-360,
		[VarSet,ZSlope,ZSlope+360]]
	
	[ISet,zscript:ZAngle,Zslope]
	//move back to mark if enables
]
[PD]
<zscriptinsert,"Widgets_Index_Include.txt">
[PD]
[PD]
[fontSetSizeSmall]\C00e0e0Digit Widget Angle Revision 3.3, created by Digits\Cc0c0c0
